<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"> 
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <title>后台</title>
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css">
    
    <script src="__PUBLIC__/layui/layui.js"></script>
    <script src="__PUBLIC__/admin/js/jquery.min.js"></script>
 
</head>
<style type="text/css">
    .login-main {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: 350px;
        margin: 0 auto;
    }
     
    .login-main header {
        margin-top: 150px;
        height: 35px;
        line-height: 35px;
        font-size: 30px;
        font-weight: 100;
        text-align: center;
    }
     
    .login-main header, .login-main form, .login-main form .layui-input-inline {
        margin-bottom: 15px;
    }
     
    .login-main form .layui-input-inline, .login-main form .layui-input-inline input, .login-main form .layui-input-inline button {
        width: 100%;
    }
     
    .login-main form .login-btn {
        margin-bottom: 5px;
}
</style>
<body class="custom-background-image1" >
 
    <div class="login-main" >
        <header class="layui-elip">登录-后台</header>
        <form class="layui-form">
            <div class="layui-input-inline">
                <input type="text" name="account" required lay-verify="required" placeholder="用户名" autocomplete="off"
                       class="layui-input">
            </div>
            <div class="layui-input-inline">
                <input type="password" name="password" required lay-verify="required" placeholder="密码" autocomplete="off"
                       class="layui-input">
            </div>
            <div class="layui-input-inline">
                <input type="text" name="code" required lay-verify="required" placeholder="验证码" autocomplete="off" class="layui-input" style="width: 50%;float: left;">
                <img id="imgcode" onclick="changeCode()" src="{:U('/admin.php/common/verify')}" style="width: 50%;float: right;height: 38px;">
            </div>
            <div class="layui-input-inline login-btn">
                <button lay-submit lay-filter="login" class="layui-btn">登录</button>
            </div>
        </form>
    </div>
     
     
    <script type="text/javascript">
        window.onload = function(){
            if(top.location!=self.location)
            {
                top.location=self.location;
            }
        }
        //重新生成验证码
        function changeCode(){
            $("#imgcode").attr("src","{:U('/admin.php/common/verify',array('timestamp'=>"+new Date().getTime()+"))}");
        }

        layui.use(['form','layer','jquery'], function () {
     
            // 操作对象
            var form = layui.form;
            var $ = layui.jquery;
            form.on('submit(login)',function (data) {
                // console.log(data.field);
                $.ajax({
                    type:'post',
                    url:"{:U('/admin.php/Common/ctrl_login')}",
                    data:data.field,
                    dataType:'json',
                    success:function (rtJson) {
                        if (rtJson.code == 1){
                            location.href = "{:U('/admin.php/Index/index')}";

                        }else{
                            layer.msg(rtJson.msg);
                            $("#imgcode").attr("src","{:U('/admin.php/common/verify',array('timestamp'=>"+new Date().getTime()+"))}");
                        }
                    }
                })
                return false;
            })
     
        });

        
    </script>
</body>
</html>